package org.ewancle.springbootelasticsearch.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Setting;

import java.time.LocalDateTime;

/*@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "#{@environment.getProperty('app.index.name', 'products')}")
@Setting(
        shards = "#{@environment.getProperty('app.index.shards', '3')}",
        //shards = "#{T(java.lang.Short).valueOf(@environment.getProperty('app.index.shards', '3'))}",
        replicas = "#{@environment.getProperty('app.index.replicas', '1')}",
        //replicas = "#{T(java.lang.Short).parseShort(@environment.getProperty('app.index.replicas', '1'))}",
        refreshInterval = "#{@environment.getProperty('app.index.refresh-interval', '1s')}"
)
public class Product {
    @Id
    private String id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String name;

    @Field(type = FieldType.Text)
    private String description;

    @Field(type = FieldType.Double)
    private Double price;

    @Field(type = FieldType.Integer)
    private Integer inventory;

    @Field(type = FieldType.Keyword)
    private String category;

    @Field(type = FieldType.Object)
    private Manufacturer manufacturer;

    @Field(type = FieldType.Date, format = {}, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    private LocalDateTime createTime;

    @Field(type = FieldType.Date, format = {}, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    private LocalDateTime updateTime;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Manufacturer {
        @Field(type = FieldType.Keyword)
        private String name;

        @Field(type = FieldType.Keyword)
        private String country;

        @Field(type = FieldType.Text)
        private String address;
    }
}*/
